﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Telerik.Web.UI;

namespace TVC_WEB.Global
{
    public partial class OrderList : System.Web.UI.Page
    {
        String sErr = "";
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void radgridOrder_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            if (Session["Username"] != null && Session["Username"] != "")
            {
                BUS.UserControl usrctr = new BUS.UserControl();
                DTO.UserInfo usrinf = usrctr.Get_Users_Email(Session["Username"].ToString(), ref sErr);
                BUS.OrderControl orderctr = new BUS.OrderControl();

                DataTable dt = orderctr.Get_ByUserID(usrinf.ID, ref sErr);
                radgridOrder.DataSource = dt;

            }
            else
                Response.Redirect("Register.aspx");
        }

        protected void radgridOrder_PreRender(object sender, EventArgs e)
        {


        }

        protected void radgridOrder_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataitem = (GridDataItem)e.DetailTableView.ParentItem;
            if (e.DetailTableView.Name == "Orders")
            {
                String orderprd = dataitem.GetDataKeyValue("OrderProducts").ToString();

                BUS.OrderProductControl ctr = new BUS.OrderProductControl();
                DataTable dt = ctr.GetByOrder(orderprd, ref sErr);

                e.DetailTableView.DataSource = dt;
            }
        }
    }
}
